﻿using System;
using System.ComponentModel.Composition;
using System.Threading;
using System.Windows;
using System.Windows.Input;
using System.Windows.Threading;

namespace PefStudio.Windows
{
    [Export(MainWindow.RibbonTabsContract, typeof(IRibbonTabItem))]
    class HomeTabItem : AbstractRibbonTabItem
    {
        public const string Contract = "Home";

        public HomeTabItem()
        {
            BaseContract = Contract;

            Header = "Home";
            ID = "Home";

            ToolTip = "Regular Tool Tip";
            ReduceOrder = "Font, Font, Font, Font,B,A,A,A,(A),(A),(A),Clipboard,Font,B,B,(A),C,(A),(A)";
        }
    }

    [Export(HomeTabItem.Contract, typeof(IRibbonGroupBox))]
    public partial class ClipboardRibbonGroupBox : AbstractRibbonGroupBox
    {
        public const string Contract = "Home.Clipboard";

        public ClipboardRibbonGroupBox()
        {
            BaseContract = Contract;

            Header = "Clipboard";
            ID = "Clipboard";

            LauncherKeys = "ZB";
            IsLauncherVisible = true;

            InitializeComponent();
        }
    }

    [Export(MainWindow.RibbonQuickAccessItemsContract, typeof(IRibbonChildItem))]
    [Export(ClipboardRibbonGroupBox.Contract, typeof(IRibbonChildItem))]
    public partial class PasteRibbonSplitButton : AbstractRibbonSplitButton
    {
        public static RoutedCommand CustomRoutedCommand = new RoutedCommand("lala", typeof(PasteRibbonSplitButton));

        public PasteRibbonSplitButton()
        {
            Header = "Paste";
            ID = "Paste";

            Icon = @"Images\Paste.png";
            LargeIcon = @"Images\PasteLarge.png";
            SizeDefinition = "Large";
            ToolTip = new Fluent.ScreenTip
                                {
                                    Title = "Paste (Ctrl+V)",
                                    Text = "Paste the contents of the Clipboard.",
                                    Width = 190
                                };

            InitializeComponent();
        }

        private void OnMenuItemClick(object sender, RoutedEventArgs e)
        {
        }
    }

    [Export(ClipboardRibbonGroupBox.Contract, typeof(IRibbonChildItem))]
    public class CutRibbonButton : AbstractRibbonButton
    {
        public CutRibbonButton()
        {
            Header = "Cut";
            ID = "Cut";

            SizeDefinition = "Middle,Small";
            Icon = @"Images\Cut.png";
            ToolTip = new Fluent.ScreenTip
                          {
                              Title = "Cut (Ctrl+X)",
                              Text = "Cut the contents to the Clipboard.",
                              Width = 190
                          };
        }
    }

    [Export(MainWindow.RibbonQuickAccessItemsContract, typeof(IRibbonChildItem))]
    [Export(ClipboardRibbonGroupBox.Contract, typeof(IRibbonChildItem))]
    public partial class CopyRibbonButton : AbstractRibbonButton
    {
        public CopyRibbonButton()
        {
            Header = "Copy";
            ID = "Copy";

            SizeDefinition = "Middle,Small";
            Icon = @"Images\Copy.png";

            InitializeComponent();

            this.Click += new RoutedEventHandler(CopyRibbonButton_Click);
        }

        void CopyRibbonButton_Click(object sender, RoutedEventArgs e)
        {
        }

        private void OnCopyClick(object sender, RoutedEventArgs e)
        {
        }
    }

    [Export(MainWindow.RibbonQuickAccessItemsContract, typeof(IRibbonChildItem))]
    [Export(ClipboardRibbonGroupBox.Contract, typeof(IRibbonChildItem))]
    public partial class FormatPainterRibbonButton : AbstractRibbonButton
    {
        public FormatPainterRibbonButton()
        {
            Header = "Format Painter";
            ID = "FormatPainter";

            SizeDefinition = "Middle,Small";

            InitializeComponent();
        }
    }

    [Export(HomeTabItem.Contract, typeof(IRibbonGroupBox))]
    public partial class FontRibbonGroupBox : AbstractRibbonGroupBox
    {
        public const string Contract = "Home.Font";

        public FontRibbonGroupBox()
        {
            BaseContract = Contract;

            Header = "Font";
            ID = "Font";

            LauncherKeys = "NF";
            IsLauncherVisible = true;

            InitializeComponent();
        }
    }

    [Export(FontRibbonGroupBox.Contract, typeof(IRibbonToolBar))]
    public partial class FontRibbonToolBar : AbstractRibbonToolBar
    {
        public const string Contract = "Home.Font";

        public FontRibbonToolBar()
        {
            BaseContract = Contract;

            Header = "Font";
            ID = "Font";

            InitializeComponent();
        }
    }

    //[Export(FontRibbonToolBar.Contract, typeof(IRibbonToolBarLayoutDefinition))]
    //public class FontLargeLayoutDefinition : AbstractRibbonToolBarLayoutDefinition
    //{
    //    public const string Contract = "Home.Font.Large";

    //    public FontLargeLayoutDefinition()
    //    {
    //        BaseContract = Contract;

    //        ID = "FontLarge";
    //        Size = RibbonControlSize.Large;
    //    }
    //}

    //[Export(FontLargeLayoutDefinition.Contract, typeof(IRibbonToolBarRow))]
    //public class FontLargeRow1 : AbstractRibbonToolBarRow
    //{
    //    public const string Contract = "Home.Font.Large.1";

    //    public FontLargeRow1()
    //    {
    //        BaseContract = Contract;

    //        ID = "FontLargeRow1";
    //    }
    //}

    //[Export(FontLargeRow1.Contract, typeof(IRibbonToolBarControlDefinition))]
    //class RibbonToolBarControlDefinition1 : AbstractRibbonToolBarControlDefinition
    //{
    //    public RibbonToolBarControlDefinition1()
    //    {
    //        ID = "RibbonToolBarControlDefinition1";
    //        Target = "FontNameRibbonComboBox";
    //        Width = 75;
    //    }
    //}

    //[Export(FontLargeRow1.Contract, typeof(IRibbonToolBarControlDefinition))]
    //class RibbonToolBarControlDefinition2 : AbstractRibbonToolBarControlDefinition
    //{
    //    public RibbonToolBarControlDefinition2()
    //    {
    //        ID = "RibbonToolBarControlDefinition2";
    //        Target = "FontSizeRibbonComboBox";
    //        Width = 45;
    //    }
    //}

    //[Export(FontLargeRow1.Contract, typeof(IRibbonToolBarControlGroupDefinition))]
    //public class RibbonToolBarControlGroupDefinition2 : AbstractRibbonToolBarControlGroupDefinition
    //{
    //    public const string Contract = "Home.Font.Large.1.1";

    //    public RibbonToolBarControlGroupDefinition2()
    //    {
    //        BaseContract = Contract;

    //        ID = "FontLargeRow1.1";
    //    }
    //}

    //[Export(FontLargeLayoutDefinition.Contract, typeof(IRibbonToolBarRow))]
    //public class FontLargeRow2 : AbstractRibbonToolBarRow
    //{
    //    public const string Contract = "Home.Font.Large.2";

    //    public FontLargeRow2()
    //    {
    //        BaseContract = Contract;

    //        ID = "FontLargeRow2";
    //    }
    //}

    //[Export(FontLargeRow2.Contract, typeof(IRibbonToolBarControlGroupDefinition))]
    //public class RibbonToolBarControlGroupDefinition1 : AbstractRibbonToolBarControlGroupDefinition
    //{
    //    public const string Contract = "Home.Font.Large.2.1";

    //    public RibbonToolBarControlGroupDefinition1()
    //    {
    //        BaseContract = Contract;

    //        ID = "FontLargeRow2.1";
    //    }
    //}

    //[Export(RibbonToolBarControlGroupDefinition1.Contract, typeof(IRibbonToolBarControlDefinition))]
    //class RibbonToolBarControlDefinition3 : AbstractRibbonToolBarControlDefinition
    //{
    //    public RibbonToolBarControlDefinition3()
    //    {
    //        ID = "RibbonToolBarControlDefinition3";
    //        Target = "BoldRibbonButton";
    //    }
    //}
    //[Export(RibbonToolBarControlGroupDefinition1.Contract, typeof(IRibbonToolBarControlDefinition))]
    //class RibbonToolBarControlDefinition4 : AbstractRibbonToolBarControlDefinition
    //{
    //    public RibbonToolBarControlDefinition4()
    //    {
    //        ID = "RibbonToolBarControlDefinition4";
    //        Target = "ItalicRibbonButton";
    //    }
    //}

    //[Export(FontRibbonToolBar.Contract, typeof(IRibbonChildItem))]
    //public class FontNameRibbonComboBox : AbstractRibbonComboBox
    //{
    //    public FontNameRibbonComboBox()
    //    {
    //        Header = "FontName";
    //        ID = "FontName";

    //        MinWidth = 40;
    //        Height = 22;
    //        BorderBrush = Brushes.Gainsboro;
    //        //Foreground = Brushes."#FF222222";
    //        GroupBy = "Tag";
    //        DisplayMemberPath = "Text";
    //        IsTextSearchEnabled = true;
    //        ResizeMode = ContextMenuResizeMode.Vertical;
    //        SizeDefinition = "Small";
    //        SelectedIndex = 0;

    //        Items.Add(new TextBlock { Text = "Arial", Tag = "Theme Fonts" });
    //        Items.Add(new TextBlock { Text = "Tahoma", Tag = "Theme Fonts" });
    //        Items.Add(new TextBlock { Text = "Tahoma", Tag = "Recent Used Fonts" });
    //        Items.Add(new TextBlock { Text = "Arial", Tag = "AllFonts" });
    //        Items.Add(new TextBlock { Text = "Segoe UI", Tag = "AllFonts" });
    //        Items.Add(new TextBlock { Text = "Tahoma", Tag = "AllFonts" });
    //        Items.Add(new TextBlock { Text = "Webdings", Tag = "AllFonts" });
    //        Items.Add(new TextBlock { Text = "Winding", Tag = "AllFonts" });
    //    }
    //}

    //[Export(FontRibbonToolBar.Contract, typeof(IRibbonChildItem))]
    //public class FontSizeRibbonComboBox : AbstractRibbonComboBox
    //{
    //    public FontSizeRibbonComboBox()
    //    {
    //        Header = "FontSize";
    //        ID = "FontSize";

    //        Width = 49;
    //        Height = 22;
    //        BorderBrush = Brushes.Gainsboro;
    //        //Foreground = Brushes."#FF222222";
    //        DisplayMemberPath = "Text";
    //        ResizeMode = ContextMenuResizeMode.Vertical;
    //        SizeDefinition = "Small";
    //        SelectedIndex = 1;
    //        Text = "12";
    //        IsEditable = false;
    //        HorizontalAlignment = HorizontalAlignment.Left;

    //        Items.Add(new TextBlock { Text = "7" });
    //        Items.Add(new TextBlock { Text = "8" });
    //        Items.Add(new TextBlock { Text = "9" });
    //        Items.Add(new TextBlock { Text = "10" });
    //        Items.Add(new TextBlock { Text = "11" });
    //        Items.Add(new TextBlock { Text = "12" });
    //        Items.Add(new TextBlock { Text = "14" });
    //        Items.Add(new TextBlock { Text = "18" });
    //    }
    //}

    //[Export(FontLargeRow1.Contract, typeof(IRibbonChildItem))]
    //[Export(FontRibbonToolBar.Contract, typeof(IRibbonChildItem))]
    //public class GrowFontRibbonButton : AbstractRibbonButton
    //{
    //    public GrowFontRibbonButton()
    //    {
    //        Header = "GrowFont";
    //        ID = "GrowFont";

    //        SizeDefinition = "Small";
    //        HorizontalAlignment = HorizontalAlignment.Left; 
    //        Icon = @"Images\GrowFont.png";
    //    }
    //}

    //[Export(FontLargeRow1.Contract, typeof(IRibbonChildItem))]
    //[Export(FontRibbonToolBar.Contract, typeof(IRibbonChildItem))]
    //public class ShrinkFontRibbonButton : AbstractRibbonButton
    //{
    //    public ShrinkFontRibbonButton()
    //    {
    //        Header = "ShrinkFont";
    //        ID = "ShrinkFont";

    //        SizeDefinition = "Small";
    //        HorizontalAlignment = HorizontalAlignment.Left;
    //        Icon = @"Images\ShrinkFont.png";
    //    }
    //}

    //[Export(FontLargeRow1.Contract, typeof(IRibbonChildItem))]
    //[Export(FontRibbonToolBar.Contract, typeof(IRibbonChildItem))]
    //public class ChangeCaseRibbonDropDownButton : AbstractRibbonDropDownButton
    //{
    //    public ChangeCaseRibbonDropDownButton()
    //    {
    //        Header = "ChangeCase";
    //        ID = "ChangeCase";

    //        SizeDefinition = "Small";
    //        HorizontalAlignment = HorizontalAlignment.Left;
    //        Icon = @"Images\ChangeCase.png";
    //    }
    //}

    //[Export(FontLargeRow1.Contract, typeof(IRibbonChildItem))]
    //[Export(FontRibbonToolBar.Contract, typeof(IRibbonChildItem))]
    //public class ClearFormattingRibbonButton : AbstractRibbonButton
    //{
    //    public ClearFormattingRibbonButton()
    //    {
    //        Header = "ClearFormatting";
    //        ID = "ClearFormatting";

    //        SizeDefinition = "Small"; 
    //        HorizontalAlignment = HorizontalAlignment.Left;
    //        Icon = @"Images\ClearFormatting.png";
    //    }
    //}

    //[Export(FontRibbonToolBar.Contract, typeof(IRibbonChildItem))]
    //public class BoldRibbonToggleButton : AbstractRibbonToggleButton
    //{
    //    public BoldRibbonToggleButton()
    //    {
    //        Header = "Bold";
    //        ID = "Bold";

    //        SizeDefinition = "Small";
    //        HorizontalAlignment = HorizontalAlignment.Left;
    //        Icon = @"Images\Bold.png";
    //    }
    //}

    //[Export(FontRibbonToolBar.Contract, typeof(IRibbonChildItem))]
    //public class ItalicRibbonToggleButton : AbstractRibbonToggleButton
    //{
    //    public ItalicRibbonToggleButton()
    //    {
    //        Header = "Italic";
    //        ID = "Italic";

    //        SizeDefinition = "Small";
    //        HorizontalAlignment = HorizontalAlignment.Left;
    //        Icon = @"Images\Italic.png";
    //    }
    //}

    //[Export(FontLargeRow2.Contract, typeof(IRibbonChildItem))]
    //[Export(FontRibbonToolBar.Contract, typeof(IRibbonChildItem))]
    //public class UnderlineRibbonDropDownButton : AbstractRibbonDropDownButton
    //{
    //    public UnderlineRibbonDropDownButton()
    //    {
    //        Header = "Underline";
    //        ID = "Underline";

    //        SizeDefinition = "Small";
    //        HorizontalAlignment = HorizontalAlignment.Left;
    //        Icon = @"Images\Underline.png";
    //    }
    //}

    //[Export(FontLargeRow1.Contract, typeof(IRibbonChildItem))]
    //[Export(FontRibbonToolBar.Contract, typeof(IRibbonChildItem))]
    //public class StrikethroughRibbonButton : AbstractRibbonButton
    //{
    //    public StrikethroughRibbonButton()
    //    {
    //        Header = "Strikethrough";
    //        ID = "Strikethrough";

    //        SizeDefinition = "Small";
    //        HorizontalAlignment = HorizontalAlignment.Left;
    //        Icon = @"Images\Strikethrough.png";
    //    }
    //}

    //[Export(FontLargeRow1.Contract, typeof(IRibbonChildItem))]
    //[Export(FontRibbonToolBar.Contract, typeof(IRibbonChildItem))]
    //public class SubscriptRibbonButton : AbstractRibbonButton
    //{
    //    public SubscriptRibbonButton()
    //    {
    //        Header = "Subscript";
    //        ID = "Subscript";

    //        SizeDefinition = "Small";
    //        HorizontalAlignment = HorizontalAlignment.Left;
    //        Icon = @"Images\Subscript.png";
    //    }
    //}

    //[Export(FontLargeRow1.Contract, typeof(IRibbonChildItem))]
    //[Export(FontRibbonToolBar.Contract, typeof(IRibbonChildItem))]
    //public class SuperscriptRibbonButton : AbstractRibbonButton
    //{
    //    public SuperscriptRibbonButton()
    //    {
    //        Header = "Superscript";
    //        ID = "Superscript";

    //        SizeDefinition = "Small";
    //        HorizontalAlignment = HorizontalAlignment.Left;
    //        Icon = @"Images\Superscript.png";
    //    }
    //}

    //[Export(FontLargeRow2.Contract, typeof(IRibbonChildItem))]
    //[Export(FontRibbonToolBar.Contract, typeof(IRibbonChildItem))]
    //public partial class TextEffectsRibbonDropDownButton : AbstractRibbonDropDownButton
    //{
    //    public TextEffectsRibbonDropDownButton()
    //    {
    //        Header = "TextEffects";
    //        ID = "TextEffects";

    //        SizeDefinition = "Small";
    //        HorizontalAlignment = HorizontalAlignment.Left;

    //        InitializeComponent();
    //    }
    //}

    //[Export(FontLargeRow2.Contract, typeof(IRibbonChildItem))]
    //[Export(FontRibbonToolBar.Contract, typeof(IRibbonChildItem))]
    //public partial class TextHighlightColorRibbonDropDownButton : AbstractRibbonDropDownButton
    //{
    //    public TextHighlightColorRibbonDropDownButton()
    //    {
    //        Header = "TextHighlightColor";
    //        ID = "TextHighlightColor";

    //        SizeDefinition = "Small";
    //        HorizontalAlignment = HorizontalAlignment.Left;

    //        InitializeComponent();
    //    }
    //}

    //[Export(FontLargeRow2.Contract, typeof(IRibbonChildItem))]
    //[Export(FontRibbonToolBar.Contract, typeof(IRibbonChildItem))]
    //public partial class FontColorRibbonDropDownButton : AbstractRibbonDropDownButton
    //{
    //    public FontColorRibbonDropDownButton()
    //    {
    //        Header = "FontColor";
    //        ID = "FontColor";

    //        SizeDefinition = "Small";
    //        HorizontalAlignment = HorizontalAlignment.Left;
    //        MaxDropDownHeight = 500;

    //        InitializeComponent();
    //    }
    //}

    [Export(HomeTabItem.Contract, typeof(IRibbonGroupBox))]
    public partial class ARibbonGroupBox : AbstractRibbonGroupBox
    {
        public const string Contract = "Home.A";

        public ARibbonGroupBox()
        {
            BaseContract = Contract;

            Header = "Galleries";
            ID = "A";

            IsLauncherVisible = true;

            InitializeComponent();
        }
    }

    [Export(ARibbonGroupBox.Contract, typeof(IRibbonChildItem))]
    public partial class SplitRibbonSplitButton : AbstractRibbonSplitButton
    {
        public SplitRibbonSplitButton()
        {
            Header = "Split";
            ID = "Split";

            Icon = @"Images\Default.png";
            LargeIcon = @"Images\GalleryLarge.png";
            SizeDefinition = "Large";
            MaxDropDownHeight = 100;

            InitializeComponent();
        }
    }

    [Export(HomeTabItem.Contract, typeof(IRibbonGroupBox))]
    public partial class CRibbonGroupBox : AbstractRibbonGroupBox
    {
        public const string Contract = "Home.C";

        public CRibbonGroupBox()
        {
            BaseContract = Contract;

            Header = "Themes";
            ID = "C";

            IsLauncherVisible = true;

            InitializeComponent();
        }

        private void OnSilverClick(object sender, RoutedEventArgs e)
        {
            Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, (ThreadStart)(() =>
            {
                Application.Current.Resources.BeginInit();
                Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri("pack://application:,,,/Fluent;component/Themes/Office2010/Silver.xaml") });
                Application.Current.Resources.MergedDictionaries.RemoveAt(0);
                Application.Current.Resources.EndInit();
            }));
        }

        private void OnBlackClick(object sender, RoutedEventArgs e)
        {
            Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, (ThreadStart)(() =>
            {
                Application.Current.Resources.BeginInit();
                Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri("pack://application:,,,/Fluent;component/Themes/Office2010/Black.xaml") });
                Application.Current.Resources.MergedDictionaries.RemoveAt(0);
                Application.Current.Resources.EndInit();
            }));
        }

        private void OnBlueClick(object sender, RoutedEventArgs e)
        {
            Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, (ThreadStart)(() =>
            {
                Application.Current.Resources.BeginInit();
                Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri("pack://application:,,,/Fluent;component/Themes/Office2010/Blue.xaml") });
                Application.Current.Resources.MergedDictionaries.RemoveAt(0);
                Application.Current.Resources.EndInit();
            }));
        }
    }

    [Export(HomeTabItem.Contract, typeof(IRibbonGroupBox))]
    public partial class BRibbonGroupBox : AbstractRibbonGroupBox
    {
        public const string Contract = "Home.B";

        public BRibbonGroupBox()
        {
            BaseContract = Contract;

            Header = "Spinners";
            ID = "B";

            IsLauncherVisible = true;

            InitializeComponent();
        }
    }
}
